import 'package:flutter/material.dart';

class HomeDetailPage extends StatelessWidget {
  static const routerName = "/detail";
  final message;
  HomeDetailPage(this.message);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("详情页"),
      ),
      body: WillPopScope(
        onWillPop: (){
//          当返回为true时，可以自动返回
//        当返回为false时，需要自己处理返回
          _backHome(context);
          return Future.value(false);
        },
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(this.message),
              RaisedButton(
                child: Text("回到首页"),
                onPressed: ()=>_backHome(context),
              )
            ],
          ),
        ),
      ),
    );
  }
  void _backHome(BuildContext context){
    Navigator.of(context).pop("pop message");
  }
}

